package com.huanxing.cloud.security.config;

import com.huanxing.cloud.common.core.constant.SecurityConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * 根据注解值动态注入资源服务器的相关属性
 *
 * @author lijx
 * @date 2022/6/2
 */
@Slf4j
public class HxSecurityBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

  @Override
  public void registerBeanDefinitions(
      AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
    BeanDefinition beanDefinition = new GenericBeanDefinition();
    beanDefinition.setBeanClassName(HxResourceServerConfigurerAdapter.class.getName());
    registry.registerBeanDefinition(SecurityConstants.RESOURCE_SERVER_CONFIGURER, beanDefinition);
  }
}
